package com.woniuxy.car.boss.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.car.boss.client.ProductBossClient;
import com.woniuxy.car.boss.param.product.BossAddSpecsParam;
import com.woniuxy.car.boss.param.product.BossSerchProductParam;
import com.woniuxy.car.boss.param.product.BossUpdateStock;
import com.woniuxy.car.common.resultcode.Result;
import com.woniuxy.car.product.client.ProductClient;
import com.woniuxy.car.product.client.param.AddSpecsParam;
import com.woniuxy.car.product.client.param.SerchProductParam;
import com.woniuxy.car.product.client.param.UpdateStock;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
public class ProductBossApiImpl implements ProductBossClient {
    @Resource
    private ProductClient productClient;

    @Override
    public Result searchSpu(BossSerchProductParam serchProductParam) {
        log.info("请求参数：{}",serchProductParam);
        SerchProductParam productParam = BeanUtil.copyProperties(serchProductParam, SerchProductParam.class);
        return productClient.searchSpu(productParam);
    }

    @Override
    public Result getProductDetailById(Integer productId) {
        log.info("请求参数：{}",productId);
        return productClient.getProductDetailById(productId);
    }

    @Override
    public Result getSkuInfo(List<Integer> propValueIds) {
        log.info("请求参数：{}",propValueIds);
        return productClient.getSkuInfo(propValueIds);
    }

    @Override
    public Result findSkuById(List<Integer> skuIds) {
        log.info("请求参数：{}",skuIds);
        return productClient.findSkuById(skuIds);
    }

    @Override
    public Result updateStock(BossUpdateStock updateStock) {
        log.info("请求参数：{}",updateStock);
        UpdateStock updateStock1 = BeanUtil.copyProperties(updateStock, UpdateStock.class);
        return productClient.updateStock(updateStock1);
    }

    @Override
    public Result upAllSpecsToEs() {
        log.info("无参数");
        return productClient.upAllSpecsToEs();
    }

    @Override
    public Result getAllSpecsById(Integer productsId) {
        log.info("请求参数：{}",productsId);
        return productClient.getAllSpecsById(productsId);
    }

    @Override
    public Result addSpecs(BossAddSpecsParam bossaddSpecsParam) {
        log.info("请求参数：{}",bossaddSpecsParam);
        AddSpecsParam addSpecsParam = BeanUtil.copyProperties(bossaddSpecsParam, AddSpecsParam.class);
        return productClient.addSpecs(addSpecsParam);
    }

    @Override
    public Result upOneSpecsToEs(Integer specsId) {
        log.info("请求参数：{}",specsId);
        return productClient.upOneSpecsToEs(specsId);
    }

    @Override
    public Result downOneSpecsFromEs(Integer specsId) {
        log.info("请求参数：{}",specsId);
        return productClient.downOneSpecsFromEs(specsId);
    }
}
